Skip to main content

LED Light Sequencing

In this project we build a Traffic Signal using different coloured LEDs. At any time, one particular coloured LED will glow indicating a Traffic Signal.

Circuit

Traffic Signal

Components

  • 1 Smowboard Think Mini
  • 4 male-to-female jumper wires
  • 3 100 ohm resistors
  • 1 red LED
  • 1 green LED
  • 1 yellow LED

In this circuit, we have used 3 different coloured LEDs to build a traffic signal. The LEDs will emit light when voltage is applied across them. The cathode of all the three LEDs are grounded by connecting them to the ground pin of Smowboard. To limit the flow of current a 100 ohm resistor is connected across each LED in series with the acthode side. The voltage across the different LEDs is controlled by connecting thier anode to different pins of the Smowboard. The anode of red LED is connected to pin number 2 of Smowboard. The anode of green LED is connected to the pin number 5 of Smowboard. The anode of yellow LED is conneceted to pin number 4 of Smowboard.

All the three LEDs are connected to different pins of the Smowboard. The Smowboard controls the voltage across these pins. Thus, a voltage will be applied across a particular LED depending on the traffic signal. A current will flow across the LED due to the applied voltage and the LED will glow indicating the specific traffic signal.

Flow

Traffic Signal flow


[{"id":"e0c76697.3afa98","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"50cfba1.f2e5244","type":"common/on interval","z":"e0c76697.3afa98","config_props":{"name":"","interval":"0.01"},"outputProps":{},"dependency_set":{},"x":190,"y":120,"wires":[["a901813b.2d9e8"]]},{"id":"937ba547.fb14a8","type":"smow_pin/write","z":"e0c76697.3afa98","config_props":{"name":"","pin_number":"2","level":"1"},"outputProps":{},"dependency_set":{},"x":350,"y":120,"wires":[[]]},{"id":"a7116e63.25e5c","type":"smow_pin/write","z":"e0c76697.3afa98","config_props":{"name":"","pin_number":"4","level":"0"},"outputProps":{},"dependency_set":{},"x":510,"y":120,"wires":[[]]},{"id":"a901813b.2d9e8","type":"smow_pin/write","z":"e0c76697.3afa98","config_props":{"name":"","pin_number":"5","level":"0"},"outputProps":{},"dependency_set":{},"x":660,"y":120,"wires":[["25bc618f.f3e81e"]]},{"id":"a9872d4f.86033","type":"smow_pin/write","z":"e0c76697.3afa98","config_props":{"name":"","pin_number":"2","level":"0"},"outputProps":{},"dependency_set":{},"x":340,"y":220,"wires":[["be4cb07f.e4325"]]},{"id":"d1dc6741.40f5d8","type":"smow_pin/write","z":"e0c76697.3afa98","config_props":{"name":"","pin_number":"5","level":"1"},"outputProps":{},"dependency_set":{},"x":510,"y":220,"wires":[[]]},{"id":"fa2fd387.d7c8","type":"smow_pin/write","z":"e0c76697.3afa98","config_props":{"name":"","pin_number":"5","level":"0"},"outputProps":{},"dependency_set":{},"x":340,"y":320,"wires":[["725bbe8f.af8b2"]]},{"id":"14ffc3e2.3ad54c","type":"smow_pin/write","z":"e0c76697.3afa98","config_props":{"name":"","pin_number":"4","level":"1"},"outputProps":{},"dependency_set":{},"x":510,"y":320,"wires":[[]]},{"id":"be4cb07f.e4325","type":"common/delay","z":"e0c76697.3afa98","config_props":{"name":"","period":"3"},"outputProps":{},"dependency_set":{},"x":680,"y":220,"wires":[["fa2fd387.d7c8"]]},{"id":"725bbe8f.af8b2","type":"common/delay","z":"e0c76697.3afa98","config_props":{"name":"","period":"1"},"outputProps":{},"dependency_set":{},"x":680,"y":320,"wires":[[]]},{"id":"25bc618f.f3e81e","type":"common/delay","z":"e0c76697.3afa98","config_props":{"name":"","period":"3"},"outputProps":{},"dependency_set":{},"x":820,"y":120,"wires":[["a9872d4f.86033"]]}]

To import this code to the Studio, copy it and paste it into the import nodes dialog box in the import section.

Lets understand the code,

  • The flow starts with an on interval node. All next nodes connected to it get triggered repeatedly after the specified interval of time.
  • Double click on the node to change its properties.
  • We set the time interval of the on-interval node to 2 seconds.
  • We use the pin write node to ON or OFF an LED. We set the 'pin number' property of this node as 2 and 'pin level' property as 1 to glow the red coloured LED.
  • We then connect the next pin write node and set its 'pin number' as 4 and 'pin level' as 0 to keep the yellow coloured LED OFF.
  • We again use a pin write node and set its 'pin number' as 5 and 'pin level' as 0 to keep the green LED OFF.
  • We then use a delay node to add a delay of 3 seconds before the next node, pin write runs. For the 3 seconds only the red LED glows while the other two don't glow indicating a 'STOP' signal.
  • We now use the pin write node again. We set the 'pin number' as 2 and 'pin level' as 0 to turn OFF the red LED which was glowing initially.
  • After that, we add a pin write node again. We set the 'pin number' as 5 and 'pin level' as 1 to glow the green coloured LED which was initially OFF.
  • We now use a delay node to add a delay of 3 seconds before the next node, pin write runs. For this 3 seconds, only the green LED will glow while the other two LEDs will be OFF indicating a 'GO' signal.
  • Next, we connect two pin write nodes again. We set the 'pin number' as 5 and 'pin level' as 0 for the first pin write node to turn OFF the green LED. For the second pin write node we set the 'pin number' as 4 and 'pin level' as 1 to turn ON the yellow LED.
  • We now use a delay node to add a delay of 1 second. For 1 second only the yellow LED glows while the other two LEDs remian OFF indicating. The flow doesn't restart before this node's execution is complete.
  • Now, we upload the code to the Smowboard using the upload button on the Studio.
  • We can see that the red LED glows for 3 seconds indicating a 'STOP' signal followed by the green LED which glows for the next 3 seconds indicating a 'GO' signal. Then the yellow LED glows for 1 second indicating a 'READY' signal

Output

Traffic Signal flow


Learn Coding and Electronics easily using Smowcode.